import { getAreaObj, uploadType } from '@/utils/util'

export const formConfig = {
	inline: false,
	showBtn: true,
	labelPosition: 'top',
	labelWidth: '120px',
	column: [
		{
			label: '调度机构名称',
			prop: 'organizationName',
			span: 12
		},
		{
			label: '调度安全员',
			prop: 'staffName',
			span: 12
		},
		{
			label: '调度类型',
			prop: 'dispatchTypeLabel',
			span: 12
		},
		
		{
			label: '紧急类型',
			prop: 'urgentTypeLabel',
			span: 12
		},

		{
			label: '报警类型',
			prop: 'alarmReasonLabel',
			span: 12
		},

		{
			label: '来源类型',
			prop: 'fromType',
			dicData: [
				{
					label: '报警',
					value: 1,
				},
				{
					label: '行为分析',
					value: 2,
				},
			],
			span: 12
		},
		
		{
			label: '创建人',
			prop: 'createUserName',
			span: 12,
		},
		{
			label: '创建时间',
			prop: 'createTime',
			span: 12,
		},
	],
}

export const tableConfig = {
	stripe: true,
	border: true,
	columns: [
		{ label: '调度安全员', prop: 'staffName' },
		{ label: '报警类型', prop: 'alarmReasonLabel' },
		{ label: '紧急类型', prop: 'urgentTypeLabel' },
		{ label: '创建人', prop: 'createUserName' },
		{ label: '创建时间', prop: 'createTime' },
		{
			label: '操作',
			prop: 'menu',
			width: 100,
			fixed: 'right',
		},
	],
}

export const api = {
	index: 'view_pbDispatch_page',
}
export const baseConfig = {
	pageName: '报警调度记录',
	dictcodes: [],
	rowKey: 'id',
	addLabel: '新增',
	tipLabel: 'sampleTime',
	exportMqTopic: '/ning/export/',
	api,
	paramsObj: {
		source: 1,
	},
	auth: {
		...api,
	},
	menuBtn: [
		{
			icon: 'detail',
			label: '查看',
			type: 'primary',
			operate: 'detail',
			auth: api.index,
			text: true,
			show: true,
		},
	],
	beforeOnLoadFormate: async (params) => {
		return new Promise((resolve, reject) => {
			const areaObj: any = getAreaObj(params.areas)
			resolve({
				...params,
				...areaObj,
				areas: undefined,
			})
		})
	},
	dialogConfig: {
		width: '55%',
	},
	formConfig,
	tableConfig,
	detailConfig: formConfig,
}
